//
//  TestDataModel.m
//  MantleTest
//
//  Created by wangrui on 14-1-21.
//  Copyright (c) 2014年 PPS. All rights reserved.
//

#import "TestDataModel.h"

@implementation TestDataModel


+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
             @"date": @"dt",
             @"locationName": @"name",
             @"humidity": @"main.humidity",
             @"temperature": @"main.temp",
             @"tempHigh": @"main.temp_max",
             @"tempLow": @"main.temp_min",
             @"sunrise": @"sys.sunrise",
             @"sunset": @"sys.sunset",
             @"conditionDescription": @"weather.description",
             @"condition": @"weather.main",
             @"icon": @"weather.icon",
             @"windBearing": @"wind.deg",
             @"windSpeed": @"wind.speed",
            };
}

// archive/unachieve时不会调用转换的方法
+ (NSValueTransformer *)dateJSONTransformer {
    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSNumber *dateNum) {
        return [NSDate dateWithTimeIntervalSince1970:dateNum.floatValue];
    } reverseBlock:^(NSDate *date) {
        return [NSString stringWithFormat:@"%f",[date timeIntervalSince1970]];
    }];
}

//+ (NSValueTransformer *)conditionDescriptionJSONTransformer {
//    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSArray *values) {
//        return [values firstObject];
//    } reverseBlock:^(NSString *str) {
//        return @[str];
//    }];
//}
//
//+ (NSValueTransformer *)conditionsJSONTransformer {
//    return [self conditionDescriptionJSONTransformer];
//}

@end
